package com.rocky.project.util;

import java.io.File;
import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public final class FileUtil {
	
	private FileUtil() {
	}



	/**
	 * 
	 */
	protected static Log log = LogFactory.getLog(FileUtil.class);

	/**
	 * 获取文件名的后缀名
	 * 
	 * @param fileName
	 * @return
	 */
	public static String getFileSuffix(String fileName) {
		String[] temp = fileName.split("\\.");
		return temp[temp.length - 1];
	}

	/**
	 * @return Returns the DocumentPath.
	 */
	public static String getDocumentPath(String directory,String srcFileFileName, String sn) {
		return ((directory==null)?"":directory)  +  "\\" +  sn + "." + getFileSuffix(srcFileFileName);
	}
	
	/**
	 * @return Returns the DocumentPath.
	 */
	public static String getDocumentName(String path) {
		String[] temp = path.split("\\\\");
		return temp[temp.length - 1];
	}



	public static void copyFile(File srcFile, File destFile) throws IOException {
		org.apache.commons.io.FileUtils.copyFile(srcFile, destFile);		
	}

}
